package com.zhentao.controller;

import com.zhentao.dtos.Result;
import com.zhentao.model.entity.product.Category;
import com.zhentao.service.CategoryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("category")
public class CategoryController {
    @Autowired
    private CategoryService categoryService;

    @RequestMapping("getParentCategory")
    public Result getParentCategory() {
        List< Category > parentCategory = categoryService.getParentCategory();
        return Result.success( parentCategory );
    }

    @RequestMapping("getSonCategory")
    public Result getSonCategory( Integer id ) {
        List< Category > parentCategory = categoryService.getSonCategory( id );
        return Result.success( parentCategory );
    }

}
